<html>
<head>
	<title>透析助手</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.5.6/css/sm.min.css">
	<link rel="stylesheet" href="__PUBLIC__/css/swiper.css">
	<link rel="stylesheet" href="__PUBLIC__/css/style.css">
	<link rel="stylesheet" href="__PUBLIC__/css/5s.css">
	<link rel="stylesheet" href="__PUBLIC__/css/6m.css">
	<link rel="stylesheet" href="__PUBLIC__/css/iconfont.css">
    <style type="text/css">
        .pic_extra{font-size:12px;}
    </style>
</head>
<body>
	<div class="Popwindow" style="display:block;">
		<div class="PopContent ID">
			<div class="PopContentTitle">身份验证</div>
			<div class="PopContentText">
				<div class="PopContentText-input">
					<input type="hidden" id="card_pic_inp" value="<{$vo.card_pic}>" />
					<input type="text" placeholder="请输入正确的身份证号码" id="card_num" value="<{$vo.card_num}>" />
				</div>
				<div class="IdTitle">
					上传身份证照片<span>（证件号码需清晰可见）</span>
				</div>
				<div class="IdImg">
					<a>
                        <label>
                            <empty name="vo.card_pic">
                                <img src="__PUBLIC__/images/addimg.png" class="addPicBtn" style="max-height:120px;" />
                                <span class="pic_extra"></span>
                            <else />
                                <img src="<{$vo.card_pic}>" class="addPicBtn" style="max-height:120px;" />
                                <span class="pic_extra">点击图片可重新上传</span>
                            </empty>
                        </label>
                    </a>
				</div>
				<div class="IdNotice">
					关联项目医院需验证您的身份信息，请正确填写并授权我们向医院对比。我们承诺妥善保管及使用您的信息。
				</div>
				<div class="BtnGroup Btn-Popwindow NoFixed">
					<a href="<{:U('complete')}>"><button class="btn-drop" type="button">取消</button></a>
					<button class="btn-submit" id="subBtn">确定</button>
				</div>
			</div>
		</div>
	</div>
    <!-- 上传照片iframe开始 -->
    <div style="visibility:hidden;width:100%;overflow-x:hidden;">
        <iframe name='img_frame' id="img_frame" style="visibility:hidden;height:1px"></iframe>
        <form id="img_form" action="<{:U('Admin/PicUpload/index')}>" encType="multipart/form-data" method="post" target="img_frame">
            <input type="file" name="pic" id="img_file" onchange="$('#img_form').submit();"/>
        </form>
    </div>
    <!-- 上传照片iframe结束 -->
    <!-- 加载动画 -->
    <div id="loadingBg" style="display:none;"></div>
<script type='text/javascript' src='__PUBLIC__/js/jquery-1.11.1.min.js'></script>
<script type='text/javascript' src='__PUBLIC__/js/myjq.js'></script>
<script>
    $(function(){
        $('#subBtn').click(function(){
            if(!isIdCode($('#card_num').val())){
                toast('请输入正确的身份证号');return;
            }
            if($('#card_pic_inp').val()==''){
                toast('请上传身份证照');return;
            }
            $('#loadingBg').show();
            $.post('<{:U("idcard")}>',
                {id:'<{$uid}>',card_num:$('#card_num').val(),card_pic:$('#card_pic_inp').val()},
                function(res){
                    $('#loadingBg').hide();
                    if(res=='suc'){
                        location.href="<{:U('Index/index')}>";
                    }else{
                        toast("保存失败");
                    }
                },
            'json');
        });
        
        //上传图片
        $(".addPicBtn").click(function(){
            $('#loadingBg').show();
            $('#img_file').click()
        });
        $('#img_frame').load(function(){
            try{
                var iframeHtml = $(this).contents().find('body').html();
            }catch(e){
                var iframeHtml = window.frames["img_frame"].document.body.innerText;
            }
            setTimeout("$('#loadingBg').hide()",1200);
            var result = $.parseJSON(iframeHtml);
            if(result.msg=='suc'){
                $('.addPicBtn').attr('src',result.url)
                $('.pic_extra').text('点击图片可重新上传');
                $('#card_pic_inp').val(result.url);
            }else{
                alert(result.msg);
            }
        });
    })
</script>
</body>
</html>